import type { TableColumn } from '@/components/core/dynamic-table';
import { formatToDateTime } from '@/utils/dateUtil';
import { Tag } from 'ant-design-vue';

export type TableListItem = API.DeptEntity;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  {
    title: '部门名称',
    dataIndex: 'deptName',
    align: 'left',
  },
  {
    title: '部门编码',
    dataIndex: 'deptCode',
    width: 120,
  },
  {
    title: '排序',
    dataIndex: 'orderNo',
    width: 50,
    hideInSearch: true,
  },
  {
    title: '状态',
    dataIndex: 'active',
    width: 80,
    hideInSearch: true,
    customRender: ({ record }) => {
      return <Tag color={record.active ? 'success' : 'error'}>{record.active ? '启用' : '禁用'}</Tag>;
    },
  },
  {
    title: '创建时间',
    dataIndex: 'creatTime',
    width: 200,
    hideInSearch: true,
    customRender: ({ record }) => formatToDateTime(record.creatTime),
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    width: 200,
    hideInSearch: true,
    customRender: ({ record }) => formatToDateTime(record.updateTime),
  },
];
